<template>
	<view class="content">
		<view class="pageHeader">
			设置
			<a class="generalBack" @click="backpage()" hover-class="none">
			 <image src="/static/b-1.png" style="width: 18upx;height: 30upx;"></image>
			 </a>
		</view>
		<view class="regoodbox" style="font-size: 30upx;color: #333;">
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" @click="gopage(1)">
				<text style="font-size: ;">个人信息</text>
				<image src="../../static/m-right.png" style="width: 12upx;height: 22upx;"></image>
			</view>
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;"  @click="gopage(2)">
				<text style="font-size: ;">密码修改</text>
				<image src="../../static/m-right.png" style="width: 12upx;height: 22upx;"></image>
			</view>
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;"  @click="gopage(8)">
				<text style="font-size: ;">安全密码修改</text>
				<image src="../../static/m-right.png" style="width: 12upx;height: 22upx;"></image>
			</view>
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" @click="gopage(3)" >
				<text style="font-size: ;">更改手机号</text>
				<image src="../../static/m-right.png" style="width: 12upx;height: 22upx;"></image>
			</view>
			<view v-if="!is_bind"  @click="gopage(5)" style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" >
				<text style="font-size: ;">绑定微信</text>			
				<image  src="../../static/m-right.png" style="width: 12upx;height: 22upx;"></image>
			</view>
			<view  v-if="is_bind"  style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" >
				<text style="font-size: ;">绑定微信</text>
				<text  style="color: #EC6104;">微信已绑定</text>				
				<!-- <text  @click="unbind" style="color: #EC6104;">解除绑定</text>				 -->
			</view>
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" @click="gopage(4)" >
				<text style="font-size: ;">清空缓存</text>
			</view>
			<view style="padding: 24upx 0;display: flex;justify-content: space-between;align-items: center;border-bottom: 2upx solid #eee;" >
				<text style="font-size: ;">版本信息</text>
				<text>{{version}}</text>
			</view>
			
			<button @click="gopage(6)" class="logout">退出登录</button>
			<view style="text-align: center;font-size: 22upx;color: #999;margin-top: 120upx;line-height: 40upx;">
				<view>Copyright&copy2018-2020</view>
				<view>三道咨询管理有限公司</view>
				<view>weishi2020.com版权所有</view>
			</view>
		</view>
	</view>
	</template>
	<script>
	import postAjax from '../../API/postAjax.js'
	export default {
		data() {
			return {
				userToken:'',// token
				is_bind:0,
				version:'',
			}
		},
		onLoad(options) {
			let that = this
			that.userToken = uni.getStorageSync('token')
			let userinfo=uni.getStorageSync('userinfo')
			that.version = uni.getStorageSync("version")			
			if(userinfo.weixin_openid || userinfo.weixin_unionid ){				
				that.is_bind=1				
			}
			
		},
		methods: {
			// 返回上一页
			backpage(){
				uni.switchTab({
					url:'../tab/my'
				})
			},
			unbind(){
				let that = this
				
				uni.showModal({
					title: '提示',
					content: '是否确认解除微信绑定？',
					success: function(res) {
						if (res.confirm) {		
							console.log(that.userToken);
							postAjax('User/wxUnbind', {token:that.userToken}, function(data) {
								console.log(data);
								uni.setStorageSync('userinfo',data.data)
								uni.showToast({
									icon: 'none',
									title: data.msg
								})														
								if(data.code == 0) {								
									that.is_bind=0								
									
								} 
							})
						}
					}
				});
			},
			gopage(type){
				if(type==1){
					uni.navigateTo({
						url:'setting/person',
						animationDuration:300
					})
				}
				if(type==2){
					uni.navigateTo({
						url:'setting/password',
						animationDuration:300
					})
				}
				if(type==3){
					uni.navigateTo({
						url:'setting/phone',
						animationDuration:300
					})
				}
				if(type==4){
					uni.showToast({
					  title:'已清除成功',
					  icon:'none'
					})	
				}
				
				if(type==5){
					uni.navigateTo({
						url:'setting/wxbind',
						animationDuration:300
					})
				}
				
				if(type==6){
					uni.removeStorageSync('token');
					uni.reLaunch({
						url:'../login/login',
					})
				}
				
				if(type==8){
					
					uni.navigateTo({
						url:'setting/safeword',
						animationDuration:300
					})
				}
			}
			
		}
	}
	
</script>

<style>
	.content{min-height: 100vh;background-color: #fff;}
	.pageHeader{height: 128upx;background-color: #1D84E8;line-height: 128upx;text-align: center;font-size: 36upx;color: #fff;padding-top: 40upx;}
	.generalBack{position: absolute;top:40upx;left:30upx;display: block;}
	.regoodbox{padding-top: 128upx;padding: 0 30upx;}
	.logout{display: block;width: 456upx;height: 80upx;line-height: 80upx;color: #1D84E8;font-size: 30upx;border:2upx solid #1D84E8;background-color: #fff;margin-top: 230upx;}
	.logout::after{border: none;}
</style>
